package com.example.venue_reservation_service.vo.excel;


import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.*;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalTime;

import com.example.venue_reservation_service.converter.LocalDateStringConverter;
import com.example.venue_reservation_service.converter.LocalTimeStringConverter;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

@Data
@Builder
@HeadRowHeight(value = 30) // 头部行高
@ContentRowHeight(value = 25) // 内容行高
@ColumnWidth(value = 20) // 列宽
// 头字体设置成16, 字体默认宋体
@HeadFontStyle(fontName = "宋体", fontHeightInPoints = 16)
// 内容字体设置成16, 字体默认宋体
@ContentFontStyle(fontName = "宋体", fontHeightInPoints = 16)
@AllArgsConstructor
public class ReservationExcel implements Serializable {

    @ExcelProperty("预约记录编号")
    private Integer id;

    @ExcelProperty("用户编号")
    private Integer userId;

    @ExcelProperty("场地编号")
    private Integer venueId;

    @ExcelProperty(value = "预约开始时间", converter = LocalTimeStringConverter.class)
    private LocalTime startTime;

    @ExcelProperty(value = "预约结束时间", converter = LocalTimeStringConverter.class)
    private LocalTime endTime;

    @JsonFormat(pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ExcelProperty(value = "预约日期", converter = LocalDateStringConverter.class)
    private LocalDate reservationDate;

    // 获取时间段标识（上午、下午、晚上）
    public String getTimeSlot() {
        if (startTime.isBefore(LocalTime.of(12, 0))) {
            return "morning";
        } else if (startTime.isBefore(LocalTime.of(17, 0))) {
            return "afternoon";
        } else {
            return "evening";
        }
    }

    // 获取星期几
    public String getDayOfWeek() {
        return reservationDate.getDayOfWeek().toString().toLowerCase();
    }
}
